package com.aigou.admin.service.impl;

import com.aigou.admin.dao.ProductDao;
import com.aigou.admin.dao.Receiving_addressDao;
import com.aigou.admin.dao.impl.ProductDaoImpl;
import com.aigou.admin.dao.impl.Receiving_addressDaoImpl;
import com.aigou.admin.entity.PageEntity;
import com.aigou.admin.entity.Receiving_address;
import com.aigou.admin.entity.ShopCart;
import com.aigou.admin.service.Receiving_addressService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Author: xsc_hunter
 * @Date: 2024/12/4) 上午11:20
 * @Version: 1.0
 */
@Service
@AllArgsConstructor
public class Receiving_addressServiceImpl implements Receiving_addressService {

    private Receiving_addressDao receivingAddressDao;

    @Override
    public PageEntity<Receiving_address> findShopCartByPage(Integer current, Integer pageSize) {
        int total = receivingAddressDao.selectCount();
        List<Receiving_address> receiving_address = receivingAddressDao.selectReceivingAddressByLimit((current - 1) * pageSize, pageSize);
        PageEntity<Receiving_address> pageEntity = new PageEntity<>();
        pageEntity.setTotal(total);
        pageEntity.setPageSize(pageSize);
        pageEntity.setRecords(receiving_address);
        return pageEntity;
    }

    @Override
    public List<Receiving_address> findAll() {
        return receivingAddressDao.selectAll();
    }

    @Override
    public Receiving_address findById(String id) {
        return receivingAddressDao.selectById(id);
    }

    @Override
    public Boolean save(Receiving_address receiving_address) {
        return receivingAddressDao.insert(receiving_address);
    }

    @Override
    public Boolean update(Receiving_address receiving_address) {
        return receivingAddressDao.update(receiving_address);
    }

    @Override
    public Boolean remove(String id) {
        return receivingAddressDao.delete(id);
    }
}
